<?php
/**
 * <https://y.st./>
 * Copyright © 2015-2016, 2018 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org./licenses/>.
**/

// Older research, now generalized
foreach(array(
	'ccTLDs'        => 'ccTLDs',
	'index'         => 'best_ccTLDs',
	'special-use'   => 'special-use_domains',
	'usable_ccTLDs' => 'usable_ccTLDs',
) as $key => $value):
	$moved["en/domain_research/$key.xhtml"] = "en/URI_research/$value.xhtml";
endforeach;

// Moved directories
foreach(array(
	'weblog/',
	'weblog/2015/',
	'weblog/2015/03-March/',
	'weblog/2015/04-April/',
	'weblog/2015/05-May/',
	'weblog/2015/06-June/',
	'weblog/2015/07-July/',
) as $value):
	$moved[$value.'index.xhtml'] = 'en/'.$value.'index.xhtml';
endforeach;

// Non-weblog files that were moved
foreach(array(
	'a/contact.xhtml',
	'a/hall_of_shame.xhtml',
) as $value):
	$moved[$value] = 'en/'.$value;
endforeach;

// March
for($i=7;$i<=31;$i++):
	$value = 'weblog/2015/03-March/'.sprintf('%02d', $i).'.xhtml';
	$moved[$value] = 'en/'.$value;
endfor;

// April
for($i=1;$i<=30;$i++):
	$value = 'weblog/2015/04-April/'.sprintf('%02d', $i).'.xhtml';
	$moved[$value] = 'en/'.$value;
endfor;

// May
for($i=1;$i<=31;$i++):
	$value = 'weblog/2015/05-May/'.sprintf('%02d', $i).'.xhtml';
	$moved[$value] = 'en/'.$value;
endfor;

// June
for($i=1;$i<=30;$i++):
	$value = 'weblog/2015/06-June/'.sprintf('%02d', $i).'.xhtml';
	$moved[$value] = 'en/'.$value;
endfor;

// Beginning of July
for($i=1;$i<=22;$i++):
	$value = 'weblog/2015/07-July/'.sprintf('%02d', $i).'.xhtml';
	$moved[$value] = 'en/'.$value;
endfor;

// Generate redirect files
foreach($moved as $key => $value):
	if($value):
		$xhtml = array(
			'<{title}>' => 'Sorry.',
			'<{subtitle}>' => 'We moved that file!',
			'<{copyright year}>' => '2015-2016',
			'<{body}>' => <<<END
<p>
	Sorry, we moved that file. But we know where it is!
</p>
<p>
	The page has been moved to <a href="/$value"><code>/$value</code></a>.
</p>
END
		);
	else:
		$xhtml = array(
			'<{title}>' => 'Sorry.',
			'<{subtitle}>' => 'That page has been deleted!',
			'<{copyright year}>' => '2015-2016',
			'<{body}>' => <<<END
<p>
	We apologize, but this page had to be deleted.
	An effort was made to make this website more professional-looking, and this page was deemed to be too personal in nature.
</p>
END
		);
	endif;
	$¢_build_page($key, $xhtml);
endforeach;
